package com.controller;

import com.dto.excution.ListExcution;
import com.enums.ListEnum;
import com.service.TranslationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/translation")
@RestController
public class TranslationController {
    @Autowired
    private TranslationService service;

    @ApiOperation(value = "推广逻辑")
    @PostMapping(value = "/findTranslation")
    @ResponseBody
    public ListExcution<Void> findTranslation(Integer userId,Integer pid){
        int count = service.findTranslation(userId,pid);
        if(count > 0){
            return new ListExcution<Void>(null, ListEnum.SUCCESS);
        }else{
            return new ListExcution<Void>(null, ListEnum.FAIL);
        }
    }


    @ApiOperation(value = "填充pid")
    @PostMapping(value = "/updatePid")
    @ResponseBody
    public ListExcution<Void> updatePid(Integer userId,Integer pid){
        int count = service.updatePid(userId,pid);
        if(count > 0){
            return new ListExcution<Void>(null, ListEnum.SUCCESS);
        }else{
            return new ListExcution<Void>(null, ListEnum.FAIL);
        }
    }



    @ApiOperation(value = "邀请好友详情")
    @PostMapping(value = "/findDetails")
    @ResponseBody
    public ListExcution<Map> findDetails(Integer userId,Integer limit){
        Map map = service.findDetails(userId,limit);
        return new ListExcution<Map>(map, ListEnum.SUCCESS);
    }


}
